﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace HU8.Helpers.Base
{
    public static class XElementExtension
    {
        public static string GetAttributeValue(this XElement element, string name)
        {
            try
            {
                return element.Attribute(name).Value;
            }
            catch (Exception ex)
            {
                return "";
            }
        }

        public static string GetElementValue(this XElement element, string elementName)
        {
            try
            {
                return element.Element(elementName).Value;
            }
            catch (Exception ex)
            {
                return "";
            }
        }

        public static string GetElementAttributeValue(this XElement element, string elementName, string name)
        {
            try
            {
                return element.Element(elementName).Attribute(name).Value;
            }
            catch (Exception ex)
            {
                return "";
            }
        }

    }
}
